package com.common.resource;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.PropertiesPropertySource;
import org.springframework.stereotype.Component;

import java.util.Properties;

/**
 * 解决swagger高版本无法解析地址问题
 */
@Component
public class SwaggerEnvironmentPostProcessor implements EnvironmentPostProcessor {

    @Override
    public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
        Properties properties = new Properties();
        properties.setProperty("spring.mvc.path-match.matching-strategy", "ant_path_matcher");
        environment.getPropertySources().addFirst(new PropertiesPropertySource("common.swagger", properties));
    }
}